package com.boco.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.boco.entity.EMR_ZYJCJL;

public class GetEMR_ZYJCJLData {
	
	private static final Log log = LogFactory.getLog(GetEMR_ZYJCJLData.class);
	public static List<EMR_ZYJCJL> getData()
	{
	    Connection con = null;
	    PreparedStatement pre = null;
	    ResultSet result = null;
	    List<EMR_ZYJCJL> re = new ArrayList<EMR_ZYJCJL>();
	    try
	    {
	        Class.forName("oracle.jdbc.driver.OracleDriver");
	        System.out.println("开始尝试连接数据库！");
	        String url = "jdbc:oracle:" + "thin:@172.20.21.12:1521:orcl";
	        String user = "sjzx_hxk";
	        String password = "boco#1234";
	        con = DriverManager.getConnection(url, user, password);
	        System.out.println("连接成功！");
	        
	        String sql = "select "
	        		+"a.jzlsh as ZYH,"
					+"'' as YLJGZZJGDM,"
					+"'' as YLJGMC,"
					+"a.studyuid as JCXMLSH,"
					+"'' as HZZSYH,"
					+"'' as JCBGDBH,"
					+"'' as DZSQDBH,"
					+"a.brxm as XM,"
					+"a.brxb as XB,"
					+"'' as NL,"
					+"'' as LXRDHHM,"
					+"a.jcks as KSDM,"
					+"a.jcksmc as KSMC,"
					+"a.bqmc as BQMC,"
					+"a.bfh as BFH,"
					+"a.bch as BCH,"
					+"'' as JCBGDMC,"
					+"a.jcxmdm as JCXMDM,"
					+"'' as JCXMMC,"
					+"'' as JCLBDM,"
					+"'' as JCLBMC,"
					+"'' as JCJGYCBZ,"
					+"'' as JCJG,"
					+"'' as CKZ,"
					+"'' as JCJLDW,"
					+"'' as JCBW,"
					+"'' as JCFF,"
					+"'' as JCGCMS,"
					+"'' as JCSJ,"
					+"'' as JCJL,"
					+"'' as JBZDDM,"
					+"'' as JBZDMC,"
					+"'' as BSZY,"
					+"'' as TZ,"
					+"'' as JCMD,"
					+"a.sqrgh as SQRGH,"
					+"a.sqrxm as SQRXM,"
					+"a.sqks as SQKSDM,"
					+"a.sqksmc as SQKS,"
					+"'' as SQJGDM,"
					+"'' as SQJGMC,"
					+"a.jysj as JCRQ,"
					+"a.jcysgh as JCRYGH,"
					+"a.jcys as JCRYXM,"
					+"'' as FHRGH,"
					+"'' as FHRXM,"
					+"a.jcks as JCKSDM,"
					+"a.jcksmc  as JCKS,"
					+"'' as JCJGDM,"
					+"'' as JCJGMC,"
					+"'' as JZJGDM,"

					+"to_char(a.ywscsj,'YYYY-MM-dd HH24:mi:ss') as BCRQ,"
					+"'' as ZRLSH,"
					+"'' as ORGCODE,"
					+"'' as AREACODE,"
					+"to_char(sysdate,'yyyyMMddHH24miss') as UPLOADTIME,"
					+"'' as  SOURCEID "
					+" from tb_ris_jcbg a  where a.mzzybz = 2 ";
	 
	        log.info("查询sql："+sql);
	        pre = con.prepareStatement(sql);
	        result = pre.executeQuery();
	        System.out.println("执行成功");
	        while (result.next()){
//	            System.out.println(result.getInt("YYDAH"));
	        	EMR_ZYJCJL temp = new EMR_ZYJCJL();
	        	temp.setJZJGDM(result.getString("JZJGDM"));
	        	
	        	temp.setZYH(result.getString("ZYH"));
	        	temp.setYLJGZZJGDM(result.getString("YLJGZZJGDM"));
	        	temp.setYLJGMC(result.getString("YLJGMC"));
	        	temp.setJCXMLSH(result.getString("JCXMLSH"));
	        	temp.setHZZSYH(result.getString("HZZSYH"));
	        	temp.setJCBGDBH(result.getString("JCBGDBH"));
	        	temp.setDZSQDBH(result.getString("DZSQDBH"));
	        	
	        	temp.setXM(result.getString("XM"));
	        	temp.setXB(result.getString("XB"));
	        	temp.setNL(result.getString("NL"));
	        	temp.setLXRDHHM(result.getString("LXRDHHM"));
	        	temp.setKSDM(result.getString("KSDM"));
	        	temp.setKSMC(result.getString("KSMC"));
	        	temp.setBQMC(result.getString("BQMC"));
	        	temp.setBFH(result.getString("BFH"));
	        	temp.setBCH(result.getString("BCH"));
	        	temp.setJCBGDMC(result.getString("JCBGDMC"));
	        	temp.setJCXMDM(result.getString("JCXMDM"));
	        	temp.setJCXMMC(result.getString("JCXMMC"));
	        	temp.setJCLBDM(result.getString("JCLBDM"));
	        	temp.setJCLBMC(result.getString("JCLBMC"));
	        	temp.setJCJGYCBZ(result.getString("JCJGYCBZ"));
	        	temp.setJCJG(result.getString("JCJG"));
	        	temp.setCKZ(result.getString("CKZ"));
	        	temp.setJCJLDW(result.getString("JCJLDW"));
	        	temp.setJCBW(result.getString("JCBW"));
	        	temp.setJCFF(result.getString("JCFF"));
	        	temp.setJCGCMS(result.getString("JCGCMS"));
	        	temp.setJCSJ(result.getString("JCSJ"));
	        	temp.setJCJL(result.getString("JCJL"));
	        	temp.setJBZDDM(result.getString("JBZDDM"));
	        	temp.setJBZDMC(result.getString("ZYH"));
	        	temp.setBSZY(result.getString("BSZY"));
	        	temp.setTZ(result.getString("TZ"));
	        	temp.setJCMD(result.getString("JCMD"));
	        	temp.setSQRGH(result.getString("SQRGH"));
	        	temp.setSQRXM(result.getString("SQRXM"));
	        	temp.setSQKSDM(result.getString("SQKSDM"));
	        	temp.setSQKS(result.getString("SQKS"));
	        	temp.setSQJGDM(result.getString("SQJGDM"));
	        	temp.setSQJGMC(result.getString("SQJGMC"));
	        	temp.setJCRQ(result.getString("JCRQ"));
	        	temp.setJCRYGH(result.getString("JCRYGH"));
	        	temp.setJCRYXM(result.getString("JCRYXM"));
	        	temp.setFHRGH(result.getString("FHRGH"));
	        	temp.setFHRXM(result.getString("FHRXM"));
	        	temp.setJCKSDM(result.getString("JCKSDM"));
	        	temp.setJCKS(result.getString("JCKS"));
	        	temp.setJCJGDM(result.getString("JCJGDM"));
	        	temp.setJCJGMC(result.getString("JCJGMC"));
	        	temp.setJZJGDM(result.getString("JZJGDM"));

	        	temp.setBCRQ(result.getString("BCRQ"));
	        	temp.setZRLSH(result.getString("ZRLSH"));
	        	temp.setORGCODE(result.getString("ORGCODE"));
	        	temp.setAREACODE(result.getString("AREACODE"));
	        	temp.setUPLOADTIME(result.getString("UPLOADTIME"));
	        	temp.setSOURCEID(result.getString("SOURCEID"));
	        	re.add(temp);
	        }
	    }
	    catch (Exception e)
	    {
	        e.printStackTrace();
	    }
	    finally
	    {
	        try
	        {
	            if (result != null)
	                result.close();
	            if (pre != null)
	                pre.close();
	            if (con != null)
	                con.close();
	            System.out.println("数据库连接已关闭！");
	        }
	        catch (Exception e)
	        {
	            e.printStackTrace();
	        }
	    }
		return re;
	}
}
